// pages/detail/videopay/index.js
var app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    src:'',
    pauseTime:1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
     console.log(options);
     var _this=this;
    app.paiRequest("/app/course/tcourses/courseHours", options).then(function (res) {
      var data = res.data;
      var remarks = data.remarks;
      console.log(remarks);
      if (remarks != undefined && remarks.length>0) {
        var server = app.data.server;
        _this.setData({
          server: server,
          src: server + remarks,
          teacherInfo: data.appUser,
          coursehour: data
        })
      }else{
        wx.showToast({
          title: "资源获取失败，请购买后观看",
          icon: 'none',
          duration: 3000,
          mask: true
        })
        remarks = "";
      }
      
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.videoContext = wx.createVideoContext('myVideo');
  },
  bindButtonTap:function(){
    var that=this;
    wx.chooseVideo({
      sourceType: ['album', 'camera'],
      maxDuration: 60,
      camera: ['front', 'back'],
      success: function (res) {
        that.setData({
          src: res.tempFilePath
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})